﻿<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24MapletRemoteControl/Map24MapletRemoteControl.php5");


// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------

// Get the Route ID
$RouteID=$_COOKIE['RouteID'];

// Flightproperties
// to start the Routeflight automatically
$proIdx=0;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "Control";
$property[$proIdx]->Value 	= "Start";

// Check first, if there is a RouteID
// if not stop execution
if ( ! isset($RouteID) ) die("No RouteID given");


// ------------------------------------------------------------------
// BUILDING THE REQUEST TO SHOW THE 3D ROUTE FLIGHT
// ------------------------------------------------------------------


// here are all commands defined and are put together in one ArrayOfCommands

// Slide out 3D view
$cmdIdx=0;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlComponent = new ControlComponent();
$commands[$cmdIdx]->ControlComponent->Component= "M3D";
$commands[$cmdIdx]->ControlComponent->Control= "SHOW";

// Enable the 3D view
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlComponent = new ControlComponent();
$commands[$cmdIdx]->ControlComponent->Component= "SHOWM3D";
$commands[$cmdIdx]->ControlComponent->Control= "SHOW";

// Slide out the required components for the Route flight
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlComponent = new ControlComponent();
$commands[$cmdIdx]->ControlComponent->Component= "SHOWM3DROUTE";
$commands[$cmdIdx]->ControlComponent->Control= "SHOW";

//  Pass the flight locations to the route component and set some additional properties for the flight
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlComponent = new ControlComponent();
$commands[$cmdIdx]->ControlComponent->Component= "M3DROUTE";
$commands[$cmdIdx]->ControlComponent->Control= "SHOW";
$commands[$cmdIdx]->ControlComponent->Properties=$property;

// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];

// definition of the request body of the first request
$request = new MapletRemoteControlRequest();
$request->Map24MRC = new Map24MRC();
$request->Map24MRC->Commands = $commands;

// definition of the request body of the second request
$request = new MapletRemoteControlRequest();
$request->Map24MRC = new Map24MRC();
$request->Map24MRC->Commands = $commands;


// ------------------------------------------------------------------
// EXECUTE BOTH REQUESTS
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed
$mrc = new Map24MapletRemoteControl($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $mrc->mapletRemoteControl($header,$request);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------


$resultString = "This command generates no output";

?>